#include <iostream>
#include <string>
using namespace std;

int lengthOfLongestSubstring(string s)
{
    int hash[128] = { 0 };
    int left = 0;
    int right = 0;
    int n = s.size();
    int ret = 0;
    while (right < n)
    {
        hash[s[right]]++;
        while (hash[s[right]] > 1)
        {
            hash[s[left]]--;
            left++;
        }
        ret = max(ret, right - left + 1);
        right++;

    }

    return ret;
}

int main()
{
    string s("abcabcbb");
    int ret = lengthOfLongestSubstring(s);
    cout << ret << endl;
    return 0;
}